﻿using System;

namespace GeoAPI.Geometries
{
	public class DimensionUtility
	{
		public static char ToDimensionSymbol(Dimension dimensionValue)
		{
			switch (dimensionValue)
			{
			case Dimension.Dontcare:
				return '*';
			case Dimension.True:
				return 'T';
			case Dimension.False:
				return 'F';
			case Dimension.Point:
				return '0';
			case Dimension.Curve:
				return '1';
			case Dimension.Surface:
				return '2';
			default:
				throw new ArgumentOutOfRangeException("Unknown dimension value: " + dimensionValue);
			}
		}

		public static Dimension ToDimensionValue(char dimensionSymbol)
		{
			char c = char.ToUpper(dimensionSymbol);
			if (c <= '2')
			{
				if (c == '*')
				{
					return Dimension.Dontcare;
				}
				switch (c)
				{
				case '0':
					return Dimension.Point;
				case '1':
					return Dimension.Curve;
				case '2':
					return Dimension.Surface;
				}
			}
			else
			{
				if (c == 'F')
				{
					return Dimension.False;
				}
				if (c == 'T')
				{
					return Dimension.True;
				}
			}
			throw new ArgumentOutOfRangeException("Unknown dimension symbol: " + dimensionSymbol);
		}

		public const char SymFalse = 'F';

		public const char SymTrue = 'T';

		public const char SymDontcare = '*';

		public const char SymP = '0';

		public const char SymL = '1';

		public const char SymA = '2';
	}
}
